package com.hamizhong.iflowers.web.action.admin.statics;

import net.sf.json.JSONObject;

import com.hamizhong.iflowers.service.IPurposeService;
import com.hamizhong.iflowers.utils.MyConstants;
import com.hamizhong.iflowers.web.base.MyBaseAjaxAction;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.IObjectVO;
import com.hamizhong.iflowers.web.vo.PurposeVO;

public class AjaxDeletePurposeAction extends MyBaseAjaxAction {
	
	private IPurposeService iPurposeService = null;
	
	public IPurposeService getiPurposeService() {
		return iPurposeService;
	}
	public void setiPurposeService(IPurposeService iPurposeService) {
		this.iPurposeService = iPurposeService;
	}
	
	@Override
	protected JSONObject doRequest() {
		logger.info("...invoke...AjaxDeletePurposeAction...");
		String purposeId = getRQ().getParameter("purposeId");
		IOPResultDto<IObjectVO> resultDto = new IOPResultDto<IObjectVO>();
		PurposeVO purposeVO = new PurposeVO();
		purposeVO.setPurposeId(purposeId);
		resultDto = iPurposeService.deletePurpose(purposeVO);
		JSONObject jo = new JSONObject();
		if(resultDto.isSuccess()) {
			jo.put("result", MyConstants.AJAX_SUCCESS);
		}else {
			jo.put("result", MyConstants.AJAX_FAILED_ALERT);
			jo.put("msg", resultDto.getErrorMSG());
		}
		return jo;
	}

}
